<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>opacity不透明度</title>
    <style>
      .box {
        width: 200px;
        height: 200px;
        background-color: orange;
        opacity: 0.5;
      }
      .boxInfo {
        position: relative;
      }
      /* h1是块级元素，使用绝对定位，变成定位元素，定位元素的宽高，由内容填充 */
      .boxInfo > h1 {
        position: absolute;
        top: 0;
        left: 0;
        background-color: black;
        color: #fff;
        width: 646px;
        text-align: center;
        opacity: 0.5;
      }
    </style>
  </head>
  <body>
    <div class="box">opacity不透明度</div>
    <div class="boxInfo">
      <img src="../../images/mx.png" alt="" />
      <h1>我是帅哥啊</h1>
    </div>
  </body>
</html>
